package text_2023_09_24;

import java.io.File;
import java.io.IOException;

/**
 * @author Vv
 * @version 1.0
 * @project coding_learn
 * @description
 * @date 2023/9/24 21:05:01
 */
public class Demo1 {
    public static void main(String[] args) throws IOException {
        File path = new File("d:/java/io");
        if(!path.exists()){
            System.out.println("目录不存在，开始创建目录");
            path.mkdirs();
        }
        String filename = "test01.txt";
        File f = new File(path,filename);
        if(f.exists()){
            System.out.println("我呢见已存在，可以进行后续操作");
            f.renameTo(new File(path,"text02.txt"));
            System.out.println("重命名完成");
            f.delete();
        }else{
            boolean result = f.createNewFile();
            if(result){
                System.out.println("文件创建成功");
            }
        }


    }
}
